<?php
set_time_limit(0);
$root=preg_replace('/cron$/', '', dirname(__FILE__));

require_once($root."inc.config.php");

require_once($root."initialize.php");

if(($db_msg=cron_initialize()) !== true){

	print_r("Connection error");

}else{ 

	$db=$vars["db"];

	for($i=5;$i<=15;$i++){
		$t = @mysql_num_rows($r=mysql_query("SELECT * FROM gg_users WHERE matrix_level=".$i));
		
		if($t<=0)
		{
			continue;
		}
		
		$count=1;
		while($member = mysql_fetch_assoc($r))
		{
			for($x=1;$x<=2;$x++){
				$sql = "INSERT INTO gg_users SET code='".$member['id']."-".$count."',username='".$member['id']."-".$count."',name='".$member['id']."-".$count."',ref=".$member['id'].",ref_level=".($i+1).",matrix_upline=".$member['id'].",matrix_level=".($i+1).",matrix_position=".$x.",status='normal',activated='y',activated_date='".date('Y-m-d H:i:s')."',cdate='".date('Y-m-d H:i:s')."',rank_a='10'";
				mysql_query($sql);print_r($sql."<br>");
				$new_uid=mysql_insert_id();
				
				if($new_uid>0){
					$sql = "INSERT INTO gg_purchase SET uid='".$new_uid."',total_bv='5000',cdate='".date('Y-m-d H:i:s')."',rank_a='10'";
					mysql_query($sql);print_r($sql."<br><br>");
				}
							
				$count++;
			}
		}
	}
	print_r("finish");
}
?>